# -*- mode: snippet -*-
# name: tryCatch Condition Handling and Recovery
# key: tryCatch
# contributor : Shuguang Sun
# --
tryCatch.W.E <- function(expr) { # Taken from demo(error.catching)
    W <- NULL
    w.handler <- function(w) { # warning handler
        W <<- w
        invokeRestart("muffleWarning")
    }
    list(value = withCallingHandlers(tryCatch(expr, error = function(e) e),
             warning = w.handler),
         warning = W)
}